package Application.UIEditApplication.view.ui.cell
{
	import Application.UIEditApplication.def.Manager;
	
	import XComponent.hide.XEvent;
	
	import com.utils.keymanager.Key;
	import com.utils.keymanager.KeyCombo;
	
	import def.XG;
	
	import fl.controls.Label;
	import fl.controls.TextInput;
	import fl.controls.listClasses.ListData;
	
	import flash.display.Sprite;
	import flash.events.Event;

	public class ComponentPropertyCell		extends BaseCell
	{
		private var m_width : Number;
		private var m_height : Number;
		
		private var m_pan : Sprite;
		
		private var m_lab : Label;
		private var m_input : TextInput;
		
		public function ComponentPropertyCell()
		{
			m_width = 125;
			m_height = 22;
			
			m_pan = new Sprite;

			this.addChild(m_pan);
		}
		
		override public function set data(value : Object) : void
		{
			super.data = value;
		}
		
		override public  function set listData(value:ListData):void
		{
			super.listData = value;
			
			m_pan.graphics.clear();
			
			if(value.column & 1)
			{
				if(!m_input)
				{
					m_input = new TextInput;
				}
				
				m_input.htmlText = data["propertyValue"];
				
				this.addChild(m_input);
	
				m_input.addEventListener(Event.CHANGE,textChanged,false,0,true);

				m_input.validateNow();
			}
			else
			{
				if(!m_lab)
				{
					m_lab = new Label;
				}
				
				m_lab.text = data["propertyName"];
				
				this.addChild(m_lab);
				
				m_lab.validateNow();
			}
			
			if(value.row & 1)
			{
				m_pan.graphics.beginFill(0xAACC00);
			}
			else
			{
				m_pan.graphics.beginFill(0xFFFFFF);
			}
			
			m_pan.graphics.drawRect(0,0,m_width,m_height);
			
			m_pan.graphics.endFill();
		}
		
		private function textChanged(evt :Event) : void
		{
			if(this.listData)
			{
				data["propertyValue"] = m_input.text;
				this.listData.owner.dispatchEvent(new XEvent(XEvent.XEVENT_CHANGED,data));
			}
		}
	}
}